package com.stock.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.stock.dao.INewStockDataDao;
import com.stock.entity.NewStockDataEntity;
import com.stock.service.IStockDataService;
import org.springframework.stereotype.Service;

@Service
public class StockDataService extends ServiceImpl<INewStockDataDao, NewStockDataEntity> implements IStockDataService {

    /**
     * 获取最新持仓
     * @return
     */
    @Override
    public NewStockDataEntity getNewStockData() {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("is_del",0);
        return this.getOne(queryWrapper);
    }

    /**
     * 设置最新持仓
     * @param entity
     * @return
     */
    @Override
    public boolean setNewStockData(NewStockDataEntity entity) {
        this.remove(new QueryWrapper<>());
        return this.save(entity);
    }

}
